package ytmc.setup;


/**
 * List of all supported audio formats
 *
 * @author Kicok
 */
public enum AudioFormat
{
    FMT_FLAC( "flac" ),
    FMT_MP3( "mp3" ),
    FMT_WMA( "wma" );


    private AudioFormat( String friendlyName )
    {
        this.friendlyName = friendlyName;
    }


    private String friendlyName;

    public String getFriendlyName()
    {
        return friendlyName;
    }

    public boolean hasAudioQualities()
    {
        return this != AudioFormat.FMT_FLAC;
    }


    public static final AudioFormat DEFAULT_FORMAT = AudioFormat.FMT_MP3;

    public static AudioFormat get( int i )
    {
        return AudioFormat.values()[i];
    }

    public static AudioFormat get( String friendlyName )
    {
        return get( friendlyName, DEFAULT_FORMAT );
    }

    public static AudioFormat get( String friendlyName, AudioFormat defaultAudioFormat )
    {
        for( AudioFormat audioFormat : AudioFormat.values() )
        {
            if( audioFormat.getFriendlyName().equalsIgnoreCase( friendlyName ) )
            {
                return audioFormat;
            }
        }

        return defaultAudioFormat;
    }


    public static String[] friendlyNames()
    {
        int i = 0;
        int len = AudioFormat.values().length;

        String[] friendlyNames = new String[len];
        for( AudioFormat audioFormat : AudioFormat.values() )
        {
            friendlyNames[i] = audioFormat.getFriendlyName();
            i++;
        }

        return friendlyNames;
    }
}
